#include <stdio.h>
#include <stdlib.h>

void mem_exit(void);
double *dvector(int n)
{
  double *out;
  if ((out = (double *) calloc((unsigned) n, sizeof(double))) == NULL)
    mem_exit();
  return (out);
}
double **dmatrix(int jsize ,int isize )
{
  double **out;
  int i;
  out      =(double **)malloc(jsize*sizeof(double*));
  out[0]   =(double *) calloc(jsize*isize,sizeof(double));
  for (i = 1; i < jsize; i++) {
    out[i] = out[i-1] + isize;
  }
  return (out);
}

void dmatrixfree(double **var)
{
	free(var[0]);
	free(var);
}
int *ivector(int n)
{
  int *out;
  if ((out = (int *) calloc((unsigned) n, sizeof(int))) == NULL)
    mem_exit();
  return (out);
}
int **imatrix(int m, int n)
{
  int **out;
  int i;
  if ((out = (int **) calloc((unsigned) m, sizeof(int *))) == NULL)
    mem_exit();
  for (i = 0; i < m; i++)
    out[i] = ivector(n);
  return (out);
}
void mem_exit(void)
{
  puts("Allocation fault in memory routines.\n");
  exit(1);
}
